package com.scau.yangsuiyu.estore.dababases.entity;

import javax.persistence.*;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.Objects;

/**
 * @author suiyu_yang
 * @description
 * @date 2019-06-04 19:20
 * @email suiyu_yang@163.com
 */
@Entity
public class Seller extends User {
    private int id;
    private String psw;
    private String phone;
    private String username;
    private String email;
    private String profilePhoto;
    private String nickname;
    private String truename;
    private Byte sex;
    private Date birthday;
    private String liveAddress;
    private String bornAddress;
    private Timestamp createTime;
    private Shop shop;


    @Override
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    public int getId() {
        return id;
    }

    @Override
    public void setId(int id) {
        this.id = id;
    }

    @Override
    @Basic
    @Column(name = "psw")
    public String getPsw() {
        return psw;
    }

    @Override
    public void setPsw(String psw) {
        this.psw = psw;
    }

    @Override
    @Basic
    @Column(name = "phone")
    public String getPhone() {
        return phone;
    }

    @Override
    public void setPhone(String phone) {
        this.phone = phone;
    }

    @Override
    @Basic
    @Column(name = "user_name")
    public String getUsername() {
        return username;
    }

    @Override
    public void setUsername(String username) {
        this.username = username;
    }

    @Override
    @Basic
    @Column(name = "email")
    public String getEmail() {
        return email;
    }

    @Override
    public void setEmail(String email) {
        this.email = email;
    }

    @Override
    @Basic
    @Column(name = "profile_photo")
    public String getProfilePhoto() {
        return profilePhoto;
    }

    @Override
    public void setProfilePhoto(String profilePhoto) {
        this.profilePhoto = profilePhoto;
    }

    @Override
    @Basic
    @Column(name = "nickname")
    public String getNickname() {
        return nickname;
    }

    @Override
    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    @Override
    @Basic
    @Column(name = "truename")
    public String getTruename() {
        return truename;
    }

    @Override
    public void setTruename(String truename) {
        this.truename = truename;
    }

    @Override
    @Basic
    @Column(name = "sex")
    public Byte getSex() {
        return sex;
    }

    @Override
    public void setSex(Byte sex) {
        this.sex = sex;
    }

    @Override
    @Basic
    @Column(name = "birthday")
    public Date getBirthday() {
        return birthday;
    }

    @Override
    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    @Override
    @Basic
    @Column(name = "live_address")
    public String getLiveAddress() {
        return liveAddress;
    }

    @Override
    public void setLiveAddress(String liveAddress) {
        this.liveAddress = liveAddress;
    }

    @Override
    @Basic
    @Column(name = "born_address")
    public String getBornAddress() {
        return bornAddress;
    }

    @Override
    public void setBornAddress(String bornAddress) {
        this.bornAddress = bornAddress;
    }

    @Override
    @Basic
    @Column(name = "create_time")
    public Timestamp getCreateTime() {
        return createTime;
    }

    @Override
    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @OneToOne(mappedBy = "seller", fetch = FetchType.EAGER)
    public Shop getShop() {
        return shop;
    }

    public void setShop(Shop shop) {
        this.shop = shop;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Seller seller = (Seller) o;
        return id == seller.id &&
                Objects.equals(psw, seller.psw) &&
                Objects.equals(phone, seller.phone) &&
                Objects.equals(username, seller.username) &&
                Objects.equals(email, seller.email) &&
                Objects.equals(profilePhoto, seller.profilePhoto) &&
                Objects.equals(nickname, seller.nickname) &&
                Objects.equals(truename, seller.truename) &&
                Objects.equals(sex, seller.sex) &&
                Objects.equals(birthday, seller.birthday) &&
                Objects.equals(liveAddress, seller.liveAddress) &&
                Objects.equals(bornAddress, seller.bornAddress) &&
                Objects.equals(createTime, seller.createTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, psw, phone, username, email, profilePhoto, nickname, truename, sex, birthday, liveAddress, bornAddress, createTime);
    }
}
